<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>    
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>

 <link href="<c:url value="/resources/homepage.css" />" rel="stylesheet">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Addtask</title>
<script type="text/javascript">
function validate1()
{
	var tt=document.forms.myform.task_title.value;
	var td=document.forms.myform.task_description.value;
	var to=document.forms.myform.task_owner.value;
	var af=document.forms.myform.actual_effort.value;
	var rf=document.forms.myform.remaining_effort.value;
	if(tt==null || tt=="")
	{
		alert("task title must be filed");
		return false;
	}
	else if(td==null || td=="")
		{
			alert("task description must be filed");
			return false;
		}
	else if(to==null || to=="")
		{
			alert("task owner must be filed");
			return false;
		}
	else if(rf==null || rf=="")
		{
				alert("remaining efforts must be filed");
				return false;
		}
	else if(af==null || af=="")
			{
					alert("actual efforts must be filed");
					return false;
			}
	else if(isNaN(af) >isNaN(rf))
		{
			alert("Actual efforts must be greater than remaining efforts");
			return false;
		}
	else if(!isNaN(tt))
		{
			alert("title should contain alphabet");
			return false;
		}		
	else if(isNaN(rf))
			{
			alert("remaining efforts should be numeric");
			return false;
			}
	else if(isNaN(af))
		{
				alert("actual efforts should be numeric");
				return false;
		}
    var regex = /^[a-zA-Z0-9]*$/;
    else if(!regex.test(td)) 
	{
		alert("title description should contain string");
		return false;
	}


	else
		{
		return true;
		}
}
</script>

</head>
<body>
	<div id="wrapper">
		<!-- ============ HEADER SECTION ============== -->
		<div id="header">
			<div id="headerlogo"></div>
		</div>
		<!-- ============ NAVIGATION SECTION ============== -->
		<div id="menubar">

			<ul>
					<li><a href="Project">Projects</a></li>
					<li><a href="Backlog">Backlog</a></li>
					<li><a href="SprintPlanning">Sprint Planning</a></li>
					<li><a href="Storyboard1">Sprint Tracking</a></li>
					<li><a href="logout">Logout</a></li>
				</ul>
		</div>

		<!-- ============ MIDDLE SECTION ============== -->
		<div id="m1">
			<fieldset>
				<legend>
					<h3>Task Details</h3>
				</legend>
				<input type="hidden" name="project_id" value="<%=request.getParameter("project_id")%>">
				<form:form action="saveTask" name="myform" method="get" modelAttribute="task" onSubmit="return validate1();">
				<table>
				<form:hidden path="story_id"  value='<%=request.getParameter("sid") %>'/>
				
 					 
<%-- 					<%int story_id = Integer.parseInt(request.getParameter("story_id")); --%>
<%-- 						System.out.println("story id is :"+story_id);%> --%>
					<tr>
					
						<td>Task Title</td>
						<td><form:input path="task_title" id="title"/><font color="red">[*]</font></td>
						<td></td>
						<td>Status</td>
<%-- 						<td><form:input path="status_id" value='${status_id}'/> --%>
						<td><form:select path="status_id">
									<c:forEach var="status" items="${listStatus}">
										<option value="${status.status_id}">${status.status_name}
										</option>
									</c:forEach>
							</form:select></td>
					</tr>
					<tr>
						<td>Description</td>
						<td><form:input path="task_description" /></td>
						<td></td>
						
					</tr>
					<tr>
						<td>Owner</td>
						<td><form:input path="task_owner"/></td>
						<td></td>
						<td>Actual Effort</td>
						<td><form:input path="actual_effort"/><font color="red">hrs</font></td>
					</tr>
					<tr>
							<td>Complexity</td>
						<td><form:select path="complexity_id">
									<c:forEach var="complexity" items="${listcomplexity}">
										<option value="${complexity.complexity_id}">${complexity.complexity_name}
										</option>
									</c:forEach>
								</form:select></td>
					<td></td>
						<td>Remaining Effort</td>
						<td><form:input path="remaining_effort"/><font color="red">hrs</font></td>
						
					</tr>
								
 					<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td><input type="submit" value="Save"></a>
					<input type="reset" value="CANCEL" align="right"></td>
					
					</tr>
				</table>
 </form:form>
			</fieldset>
		</div>
		
		<div id="footer">
			<p>Copyright &copy; 2014 - All Rights Reserved - Spring Computing
				Pvt. Ltd.</p>
		</div>
	</div>


</body>
